package com.pink.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import java.util.List;

public class JsonUtils {
    public static String convertObj2Json(Object object) {
        return JSON.toJSONString(object);
    }
    public static <T> T convertJson2Obj(String json, Class<T> clazz) {
        return JSON.parseObject(json, clazz);
    }
    public static <T> T convertJson2Obj(byte[] json, Class<T> clazz) {
        return JSON.parseObject(json, clazz);
    }
    public static <T> T convertJson2Obj(String json, TypeReference<T> typeReference) {return JSON.parseObject(json, typeReference);}
    public static <T> List<T> convertJsonArray2List(String json, Class<T> clazz) {return JSON.parseArray(json, clazz);}
}
